#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__author__ = "Administrator"
__name__="server"
__date__="2016/6/29"
__time__="11:21"
"""
import SocketServer
class MyServer(SocketServer.BaseRequestHandler):
    def setup(self):
        pass
    def handle(self):
        # print self.request  # 客户端socket对象
        # print self.client_address   # 客户端ip和端口
        # print self.server   # 服务端socketserver 对象
        conn = self.request

        n=conn.recv(1024)
        p=conn.recv(1024)
        print n,p
        #print send_data_p,send_data_n
        conn.send('hello!!!')
        flag = True
        while flag:

            send_data=raw_input('robot:')
            conn.send(send_data)
            data = conn.recv(1024)
            print data
            if data == 'exit':
                flag = False
        conn.close()
    def finish(self):
        pass

if __name__ == '__main__':
    server = SocketServer.ThreadingTCPServer(('127.0.0.1',9999),MyServer)
    server.serve_forever()

